package com.meadvc.ssmdemo.controller;

import com.alibaba.fastjson.JSONObject;
import com.meadvc.ssmdemo.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @program: ssm-demo
 * @description: 登录控制
 * @author: meadvc
 * @create: 2020-06-15 16:14
 **/
@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private LoginService loginService;

    /**
     * 登录
     */
    @PostMapping("/auth")
    @CrossOrigin
    public JSONObject authLogin(@RequestBody JSONObject requestJson) {

        return loginService.authLogin(requestJson);
    }
    @PostMapping("/auth2")
    @CrossOrigin
    public JSONObject authLogin2(HttpServletRequest request) {

        String username = request.getParameter("username");
        String password = request.getParameter("password");
        return loginService.authLogin2(username,password);
    }

}
